N            equ    3
M            equ    2

             org  $1000
start        move.b data,d0
             move.b #0,count
             move.b #0,d1     ; d1 is counter
x2           cmp.b  #N,d0
             bgt    x1         ; test data > N
             bra    x3         ; test data <= N
x1           sub.b  #M,d0     ; data = data - M
             add.b  #1,d1     ; increment counter
             bra    x2
x3           move.b d1,count  ; update count
             nop



              org  $10a0
data          ds.b  1
count         ds.b  1
